grammar Aufgabe2_AST;

options {
 output=AST; 
 ASTLabelType=CommonTree; 
}

tokens {RAETSEL;}

/*------------------------------------------------------------------
 * PARSER RULES
 *------------------------------------------------------------------*/
raetsel	: ( a1=zblock o1=operator a2=zblock e1=equal a3=zblock
	    o2=operator o3=operator o4=operator
	    a4=zblock o5=operator a5=zblock e2=equal a6=zblock
	    e3=equal e4=equal e5=equal
	    a7=zblock o6=operator a8=zblock e6=equal a9=zblock)
	    -> ^(RAETSEL ^($e1 ^($o1 $a1 $a2) $a3)^($e3 ^($o2 $a1 $a4) $a7)^($e2 ^($o3 $a2 $a5) $a8)^($e4 ^($o4 $a3 $a6) $a9)^($e5 ^($o5 $a4 $a5) $a6)^($e6 ^($o6 $a7 $a8) $a9));
zblock		: (Z_BLOCK)*; 

operator	: OPERATOR;

equal 		: EQUAL;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/
Z_BLOCK 	: ('A'..'H'|'J'|'K');
OPERATOR 	: ('+'|'-');
EQUAL		: ('=');
EOF 		: ('\r' | '\n')+;
WHITESPACE 	: ('\t' | ' ')+ { $channel = HIDDEN; };



